#ifndef API_CLIENT_H
#define API_CLIENT_H

#include <memory>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>

#include "common/api/result.hpp"
#include "common/api/changes.h"

#include "common/elements/element.h"
#include "common/elements/element_type.hpp"

#include "common/more/uuid.h"

namespace Api
{

class Client final
{
public:
    explicit Client(const std::string& datenaroPath);

    std::vector<unsigned> getIds(
        const Uuids::Uuid& sessionUuid,
        Elements::ElementType type,
        const std::string& filter = ""
    ) const;

    std::vector<std::shared_ptr<Elements::Element>> getElements(
        const Uuids::Uuid& sessionUuid,
        Elements::ElementType type,
        const std::vector<unsigned>& ids
    ) const;

    Api::Result addElement(
        const Uuids::Uuid& sessionUuid,
        std::shared_ptr<Elements::Element> element
    ) const;

    Api::Result setElement(
        const Uuids::Uuid& sessionUuid,
        std::shared_ptr<Elements::Element> element
    ) const;

    Api::Result delElement(
        const Uuids::Uuid& sessionUuid,
        Elements::ElementType type,
        unsigned id
    ) const;

    Api::Changes hasChanges(
        const Uuids::Uuid& sessionUuid
    ) const;

    Api::Result login(
        const std::string& user,
        const std::string& password
    ) const;

    Api::Result logout(
        const Uuids::Uuid& sessionUuid,
        const std::string& user
    ) const;

private:
    std::string url(const std::string& path) const;

private:
    const std::string m_datenaroPath;

};

} // namespace Api

#endif // API_CLIENT_H
